package PTA.javaB;

import kotlin.collections.ArraysKt;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
import java.util.concurrent.SynchronousQueue;

public class ex14 {
    public static void main(String[] args) {
Scanner sc= new Scanner(System.in);

int seed =sc.nextInt();
int n=sc.nextInt();
Object a[] = new Object[n];
//根据种子seed初始化ObjectGenerator
        ObjectGenerator b= new ObjectGenerator(seed);
for(int i=0;i<n;i++){
    a[i]=b.getObject();
}
        System.out.println(Arrays.toString(a));
for(int i=0;i<n;i++){
    //找到数组中的Person类，输出他们的name
    if(a[i] instanceof Pe){
        System.out.println(((Pe) a[i]).getName());
    }
}

    }

}
class Pe{
    String name;
    int id;
    Pe(int id,String name){
        this.name=name;
        this.id=id;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return   "id=" + id  +
                " name=" + "'"+name+"'"
                ;
    }
}
class ObjectGenerator{
    private Random random;

    public ObjectGenerator(int seed) {
        random = new Random(seed);
    }

    public Object getObject(){
        int choice = random.nextInt(3);
        int x = random.nextInt(26);
        switch (choice) {
            case 0:
                char z = (char)(97+x);
                return new String(""+z);
            case 1:
                return Integer.valueOf(x);
            case 2:
                char name = (char)(65+x);
                return new Pe(x, name+"");
        }
        return null;
    }
}

/*
import java.util.ArrayList;
        import java.util.Arrays;
        import java.util.Random;
        import java.util.Scanner;
        import java.util.concurrent.SynchronousQueue;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        ArrayList<Object> list = new ArrayList<>();
        int seed = sc.nextInt();
        int n=sc.nextInt();
        //根据种子seed初始化ObjectGenerator
        ObjectGenerator a= new ObjectGenerator(seed);
        //根据数量n，调用ObjectGenerator的getObject方法随机生n个对象放入数组
        for(int i=0;i<n;i++){
            list.add(a.getObject());
        }
        //输出数组
        System.out.println(list);
//找到数组中的Person类，输出他们的name
        for(int i=0;i<n;i++){
            if(list.get(i) instanceof Person){
                System.out.println("Name of the person is "+((Person) list.get(i)).getName());
            }
        }




    }
}
class Person{
    String name;
    int id;
    Person(int id,String name){
        this.name = name;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public int getId(){
        return id;
    }
    public void setId(int id){
        this.id =id;
    }

    @Override
    public String toString() {
        return
                "id=" + id  +
                        " name=" + "'"+name+"'"
                ;
    }
}
class ObjectGenerator{
    private Random random;

    public ObjectGenerator(int seed) {
        random = new Random(seed);
    }

    public Object getObject(){
        int choice = random.nextInt(3);
        int x = random.nextInt(26);
        switch (choice) {
            case 0:
                char z = (char)(97+x);
                return new String(""+z);
            case 1:
                return Integer.valueOf(x);
            case 2:
                char name = (char)(65+x);
                return new Person(x, name+"");
        }
        return null;
    }
}*/
